package com.example.springmvcdemo2;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/header")
public class HeaderController {

    @ResponseBody
    @RequestMapping("/h1")
    public String getHeader(HttpServletRequest request) {
        String ua = request.getHeader("User-Agent");
        return ua;
    }

    @ResponseBody
    @RequestMapping("/h2")
    public String getHeader2(@RequestHeader(value = "User-Agent") String ua) {
        return ua;
    }

}
